package com.fjnldx.mes.controller.Quota;

import com.fjnldx.mes.domain.domainReq.DeleteReq;
import com.fjnldx.mes.domain.domainRes.Result;
import com.fjnldx.mes.domain.pojo.MesDinger;
import com.fjnldx.mes.service.Quota.QuotaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/quota")
@Api(value = "定额表管理", tags = "定额表管理")
public class QuotaController {
    @Resource
    QuotaService quotaService;

    @PostMapping("/queryQuota")
    @ApiOperation(value = "查询定额", notes = "查询定额")
    public Result queryQuota(@RequestBody MesDinger data) throws Exception {
        return quotaService.queryQuota(data);
    }

    @PostMapping("/deleteQuota")
    @ApiOperation(value = "删除定额", notes = "删除定额")
    public Result deleteQuota(@RequestBody DeleteReq data) throws Exception {
        return quotaService.deleteQuota(data.getArray());
    }

    @PostMapping("/updateQuota")
    @ApiOperation(value = "更新定额", notes = "更新定额")
    public Result updateQuota(@RequestBody MesDinger data) throws Exception {
        return quotaService.updateQuota(data);
    }

    @PostMapping("/insertQuota")
    @ApiOperation(value = "新增定额", notes = "新增定额")
    public Result insertQuota(@RequestBody MesDinger data) throws Exception {
        return quotaService.insertQuota(data);
    }

    @GetMapping("/exportDingErData")
    @ApiOperation(value = "导出定额表Excel", notes = "导出定额表Excel")
    public void exportHistoricalWorkersData(HttpServletRequest request, HttpServletResponse response) throws Exception {
        quotaService.exportDingErData(request, response);
    }

    @GetMapping("/exportDingErEmpty")
    @ApiOperation(value = "导出定额表Excel模板", notes = "导出定额表Excel模板")
    public void exportDingErEmpty(HttpServletRequest request, HttpServletResponse response) throws Exception {
        quotaService.exportDingErEmpty(request, response);
    }
}
